package cn.zhiyuan.ours.controller;

import com.jfinal.core.Controller;
import com.jfinal.kit.Base64Kit;

import cn.zhiyuan.ours.model.User;

public class LoginController extends Controller {
	private User user=new User();
	public void index() {
		this.render("login.html");
	}
	public void login() {
		String useroremail=	this.getPara("useroremail");
		String password = this.getPara("password");
		user = this.user.findFirst("select * from `user` where `user` = '" + useroremail + "' or `email` = '"
				+ useroremail + "' and `password` = '" + Base64Kit.encode(password) +"'");
		if(user!=null) {
			this.setSessionAttr("usersession", user);
			this.redirect("/admin");
		}else {
			//
		}
	}
}
